package com.gump.essay.demo.jdk;

import lombok.extern.slf4j.Slf4j;

import java.time.*;
import java.time.format.DateTimeFormatter;

/**
 * @auther zzc
 * @date 2020/10/21 9:13
 */
@Slf4j
public class TimeDemo {

    public static void main(String[] args) {
        LocalDate now = LocalDate.now();
        System.out.println(now);
        int year = now.getYear();
        int monthValue = now.getMonthValue();
        int dayOfMonth = now.getDayOfMonth();
        log.info("年{}，月{}，日{}", year, monthValue, dayOfMonth);
        LocalDate date = LocalDate.of(2020, 10, 21);
        System.out.println(date);
        if (now.equals(date)) {
            System.out.println("时间相同");
        }
        MonthDay of = MonthDay.of(10, 21);
        LocalTime time = LocalTime.now();
        LocalTime localTime = time.plusHours(2);
        System.out.println(localTime);
        //https://mp.weixin.qq.com/s?__biz=MzUxOTc4NjEyMw==&mid=2247494828&idx=1&sn=95787e313252839c227bf2ceef5f0822&chksm=f9f6f748ce817e5ef981f8b1f72d35c2626b730fb3ccb101ec10b58b5e3c54ee879875d43a06&scene=126&sessionid=1603241792&key=43f22fce2a265943139edcfd011f12161f5f4199167008b44db56fc204b7f29384d1e2065fca8a7472b16cf44d0a70f8b2e0df349a028a751811bf4486df66c777ec64a288561c094aded0bbc98433f16ac0991f35a427c07bd56086098200cfd0f100f9eb5559a0b3521a96ce36d862ceabd9ba58b1d8980a380f56cc49f57e&ascene=1&uin=MTg5NDIxMTU4MQ%3D%3D&devicetype=Windows+10+x64&version=6300002f&lang=zh_CN&exportkey=Ad%2BUrFRtUiO%2Fx3bgzPGj8mc%3D&pass_ticket=oUEfOFA4K80EcQj%2BqWGWrQOAujEhqLgNDl0ImhDEsa48FI%2FUtlzlNfQccPdUsHbc&wx_header=0
        Clock clock = Clock.systemUTC();
        System.out.println(clock.millis());
        if (now.isLeapYear()) System.out.println(now.getYear() + "年是闰年");
        Instant instant = Instant.now();
        System.out.println("What is value of this instant " + instant);
        String dataString = "20201021";
        LocalDate parse = LocalDate.parse(dataString, DateTimeFormatter.BASIC_ISO_DATE);
        System.out.println("parse " + parse);
    }
}
